var d = document;
var b = d.body;
var sp;

document.addEventListener("mouseup",function(){
	speakIt();
});

function speakIt()
{
	if (d.getSelection() != "")
	{
		try
		{
			$(sp).remove();
		}
		catch(err)
		{
			console.log(err);
		}
		sp = b.insertBefore(d.createElement("audio"), b.firstChild);
		sp.id = "speak_player";
		sp.autoplay = true;
		sp.style.display = "none";
		sp.src = "http://translate.google.com/translate_tts?q=" + d.getSelection();	
	}
}